<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            margin-top: 100px;
            width: 440px;
            background-color: #ebebeb;
            margin: 0 auto;
            padding: 5px;
        }

        .inp-box {
            height: 50px;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-bottom: 5px;
        }

        .inp-box .inp {
            width: 100%;
            height: 45px;
            border: none;
            text-indent: 20px;
            font-size: 25px;
            outline: none;
        }

        .list {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            list-style: none;
        }

        .list li {
            user-select: none;
            width: 100px;
            height: 65px;
            text-align: center;
            line-height: 65px;
            font-size: 20px;
            background-color: #fff;
            margin-bottom: 10px;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div class="box">

        <div class="inp-box">
            <input id="inp" class="inp" type="text" placeholder="计算器">
        </div>
        <ul class="list">
            <li id="clear">C</li>
            <li class="back">CE</li>
            <li class="item">%</li>
            <li class="item">/</li>
            <li class="item">7</li>
            <li class="item">8</li>
            <li class="item">9</li>
            <li class="item">*</li>

            <li class="item">4</li>
            <li class="item">5</li>
            <li class="item">6</li>
            <li class="item">-</li>
            <li class="item">1</li>
            <li class="item">2</li>
            <li class="item">3</li>
            <li class="item">+</li>

            <li class="item" style="width: 210px;">0</li>
            <li class="item">.</li>
            <li id="equal">=</li>
        </ul>
    </div>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script>
        var str = '';
        $('.list').on('click','.item',function(){
            var text = $(this).text();
            str += text;

            //将字符串放在入输入框
            $('#inp').val(str);
        })
        $('#equal').on('click',function(){
            var result = eval(str);
            $('#inp').val(result);
            str = result;
        })
        $('#clear').on('click',function(){
            str = '';
            $('#inp').val('');
        })
        
        
    </script>


</body>

</html>